# 04-图书库存管理系统.py
list = [
    {"id":10086,"name":'Photshop入门到创意',"date":'2021-10-01',"price":'49.9','kc':1},
     {"id":10010,"name":'四大名著',"date":'1999-10-01',"price":'79.9','kc':1},
      {"id":10000,"name":'小红书',"date":'2017-9-01',"price":'9.9','kc':1},
    ]
# 显示书目信息
def get_book(list):
    for x in reversed(list):
        print(x['id'],'\t',x['name'],'\t',x['date'],"\t",x['price'])
# 显示图书库存
def info_kc(list):
    # 遍历渲染list
    for x in reversed(list):
        print(x['id'],"\t",x['name'],"\t",x['kc'])
# 添加书目
def add_book(list):
    id = int(input('请输入书籍编号：'))
    name = input('请输入书籍名称：')
    date = input('请输入书籍出版时间：')
    price = float(input('请输入图书定价：'))
    # 往list 添加图书  -字典 append()
    list.append({"id":id,"name":name,"date":date,"price":price,"kc":1})
# 修改图书库存
def up_book(list):
    id = int(input('请输入书籍编号'))
    flag = False
    for x in list:
        if id==x['id']:
            flag =True
            kc = int(input('请输入库存量：'))
            x['kc']=kc
    if flag==False:
            print('没有该图书')
def main(list):
    print('=============================')
    print('图书库存管理系统v1.0')
    while True:
        print('1.显示书目信息')
        print('2.显示图书库存信息')
        print("3.添加数目信息")
        print("4.修改图书库存量")
        print('5.退出系统')
        print('=============================')
        index = input('请选择您的操作：')
        if index=="1":get_book(list)
        if index=="2":info_kc(list)
        if index=="3":add_book(list)
main(list)